package com.niit.service.impl;

import java.util.List;

import com.niit.bean.Mail;
import com.niit.dao.MailDao;
import com.niit.dao.impl.MailDaoImpl;
import com.niit.service.MailService;
import com.niit.utils.Page;

public class MailServiceImpl implements MailService {

	private MailDao dao = new MailDaoImpl();
	@Override
	public int add(Mail t) {
		return dao.add(t);
	}

	@Override
	public int delete(Mail t) {
		return dao.delete(t);
	}

	@Override
	public int update(Mail t) {
		return dao.delete(t);
	}

	@Override
	public Page<Mail> getPage(String pagenum, String url) {
		int total = dao.findTotal();//查出总记录数
		Page<Mail> page = null;
		if(pagenum == null){
			page = new Page<Mail>(total,1);
		}else{
			page = new Page<Mail>(total, Integer.parseInt(pagenum));
		}
		List<Mail> list = dao.findAll(page.getStartIndex(), page.getEndIndex());
		page.setList(list);
		page.setUrl(url);
		return page;
	}

}
